﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_ReturnSortingController : BaseApiController
    {
        #region DI

        public PB_ReturnSortingController(IPB_ReturnSortingBusiness pB_ReturnSortingBus)
        {
            _pB_ReturnSortingBus = pB_ReturnSortingBus;
        }

        IPB_ReturnSortingBusiness _pB_ReturnSortingBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_ReturnSorting>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_ReturnSortingBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_ReturnSorting> GetTheData(IdInputDTO input)
        {
            return await _pB_ReturnSortingBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_ReturnSorting data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_ReturnSortingBus.AddDataAsync(data);
            }
            else
            {
                await _pB_ReturnSortingBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_ReturnSortingBus.DeleteDataAsync(ids);
        }
        /// <summary>
        /// 获取分拣列表数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<PageResult<PB_ReturnSortingDto>> GetReturnSortingListAsync(PageInput<ConditionDTO> input) {
            return await _pB_ReturnSortingBus.GetReturnSortingListAsync(input);
        }

        /// <summary>
        /// PDA提交向分拣表插入数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task AddDataListAsync(PB_ReturnSortingList data) {
            if (data.Subdata.Count>0) {
               await _pB_ReturnSortingBus.AddDataListAsync(data);
            }
        }
        /// <summary>
        /// 分拣数据 查看 /编辑/审核
        /// </summary>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PB_ReturnSortingListInfo> GetListInfo(string ParentId) {
            var list = await _pB_ReturnSortingBus.GetListInfo(ParentId);
            return list;
        }
        /// <summary>
        /// 确认改为已查看
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdataState(string Id) {
            await _pB_ReturnSortingBus.UpdataState(Id);
        }
        /// <summary>
        /// PDA项目回货生成装车吗明细
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task ReturnTransportBillDetailAdd(ReturnTransportBillDetailAdd Data) {
            await _pB_ReturnSortingBus.ReturnTransportBillDetailAdd(Data);
        }
        #endregion
    }
}